package top.healthylife.gateway.platform.youshu.api.utils;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@Slf4j
class EncryptDto {
    public EncryptDto(String uid, String api, String args) {
        this.uid = uid;
        this.api = api;
        this.args = args;
    }

    private String uid;
    private String api;
    //json
    private String args;
    private String sign;

    public void signature(String privateKey) {
        log.info("参数加密");
        String str = StrUtil.format("uid={}&api={}&args={}&key={}", this.uid, this.api, this.args, privateKey);
        log.info("待加密字符串:{}",str);
        this.sign = SecureUtil.md5(str);
        log.info("sign:{}",this.sign);
    }

    @Override
    public String toString() {
        return StrUtil.format("uid={}&api={}&args={}&sign={}", this.uid, this.api, this.args, this.sign);
    }
}